﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AmuTools;
using app.Api;

namespace app.Models
{
    [Model(TableName = "t_article", PrimaryKey = "id", IdentityInsert = true)]
    public class Article
    {
        [Field(Description = "文章唯一标识符")]
        public int id { get; set; }


        [Field(Description = "文章作者")]
        public string author { get; set; }


        [Field(Description = "文章标题")]
        public string title { get; set; }


        [Field(DataType = "text", Description = "文章内容")]
        public string content { get; set; }


        [Field(DataType = "varchar(100)", Description = "文章附带视频的文件id，多个id用逗号分隔")]
        public string video_ids { get; set; }


        private List<UploadedFile> _video = null;
        [Field(Storageable = false, Description = "文章附带的视频，为列表，意味着可以上传多个视频")]
        public List<UploadedFile> video
        {
            get
            {
                if (video_ids == "" || video_ids == null) { _video = new List<UploadedFile>(); }
                else { _video = G.DB.Get<UploadedFile>(string.Format("{0} in ({1})", G.DB.GetPrimaryKey<UploadedFile>(), video_ids)).GetFirstTableList<UploadedFile>(); }
                return _video;
            }
        }


        [Field(Description = "模块类别，空字符串代表没有类别，它目前安排取值为常用服务下的大类")]
        public string m_type { get; set; }


        [Field(Description = "文章一级类别，级别小于模块类别")]
        public string p_type { get; set; }


        [Field(Description = "文章二级类别")]
        public string a_type { get; set; }


        [Field(DataType = "char(13)", Description = "文章创建时间")]
        public string create_time { get; set; }


        [Field(Description = "文章状态：0隐藏，1显示")]
        public int status { get; set; }


        [Field(Webable = false, Description = "文章是否被删除（如果文章真的是直接删掉了则没有用到这个字段）")]
        public int is_delete { get; set; }


        [Field(Description = "被点击次数")]
        public int click_num { get; set; }


        [Field(Description = "是否置顶")]
        public int is_top { get; set; }

    }
}